package cn.hzc.fortess.core.common;


public class ResponseData {

    /**
     * 请求是否成功
     */
    private Boolean success;

    /**
     * 响应状态码
     */
    private Integer code;

    /**
     * 响应信息
     */
    private String message;

    /**
     * 响应对象
     */
    private Object data;


    public ResponseData() {
    }

    public final static ResponseData success() {
        ResponseData respone = new ResponseData();
        respone.success = true;
        respone.code = BizErrorEnum.SUCCESS.getCode();
        respone.message = BizErrorEnum.SUCCESS.getMessage();
        return respone;
    }

    public final static ResponseData success(String msg) {
        ResponseData respone = new ResponseData();
        respone.success = true;
        respone.code = BizErrorEnum.SUCCESS.getCode();
        respone.message =msg;
        return respone;
    }

    public final static ResponseData error(Integer code, String message) {
        ResponseData respone = new ResponseData();
        respone.success = false;
        respone.code = code;
        respone.message = message;
        return respone;
    }

    public ResponseData(BizErrorEnum bizException) {

        this.success = false;
        this.code = bizException.getCode();
        this.message = bizException.getMessage();
    }

    public ResponseData(Boolean success, Integer code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    public ResponseData(Boolean success, Integer code, String message, Object data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Boolean getSuccess() {
        return success;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }
}
